#!/usr/bin/bash
if [ "$1" = "" ];then
	echo "缺少输入文件"
	exit 1
fi
mkdir -p tmp
echo "生成分立音频wav文件"
cat $1 | while read line;do
	fn=$(echo $line | cut -f1 -d'-')
	length=${#fn}
	offset=$(expr $length + 1)
	txt=${line:$offset}
	echo $line
	echo ${txt} | xfttsgo -o tmp/${fn}.wav -stdin
done

echo "合并wav"
merge-timed-wav tmp

ffmpeg -i out.wav -y out.mp3

rm out.wav

rm -rf tmp
